home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / delfroml.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.1 KB  |  53 lines

  1. /*
  2. \funcref{delfromlist}{VAR\_ delfromlist (\params)}
  3.     {
  4.         {VAR\_} {v} {variable holding list to scratch from}
  5.         {char} {*s} {string to scratch from list}
  6.     }
  7.     {variable holding shrinked list}
  8.     {initvar(), xrealloc(), xstrdup()}
  9.     {inlist(), copylist()}
  10.     {delfroml.c}
  11.     {
  12.  
  13.         This function deletes string {\em s} to the list of variable {\em v}.
  14.         The same variable is returned.
  15.  
  16.         Variable {\em v} is initialized (if necessary) to accomodate an
  17.         intermediate memory allocation struct and the new element.
  18.     }
  19. */
  20.  
  21. #include "icm-exec.h"
  22.  
  23. VAR_ delfromlist (v, s)
  24. VAR_ v;
  25. char *s;
  26. {
  27.     register unsigned
  28.         i,
  29.         j;
  30.     register char
  31.         *elem;
  32.     register LIST_
  33.         *list;
  34.  
  35.     if (! v.vu.i || ! (list = &(v.vu.i->ls.list)) )
  36.         return (v);
  37.  
  38.     for (i = 0; i < list->size; i++)
  39.     {
  40.         elem = list->element [i];
  41.         if (! strcmp (s, elem))
  42.         {
  43.             for (j = i + 1; j < list->size; j++)
  44.                 list->element [j - 1] = list->element [j];
  45.             list->size--;
  46.             xrealloc (elem, 0);
  47.             i--;
  48.         }
  49.     }
  50.  
  51.     return (v);
  52. }
  53.